import { useModel } from "umi";
import { Popconfirm, Input, List, Space, message } from "antd";
import { useReactive } from "ahooks";

const AddBoss = () => {
    const { graphqlFetch } = useModel("global");

    const state = useReactive({
        loading: false,
        persons: [],
        allPersons: [],
    });

    const handleSearchMember = async (value) => {
        if (value) {
            state.loading = true;
            state.loading = false;
        } else {
            message.warn("请输入名称");
        }
    };

    const selectPerson = async (item) => {};

    return (
        <Space direction="vertical" size={20} style={{ width: "100%" }}>
            <Input.Search placeholder="搜索人员姓名" onSearch={handleSearchMember} allowClear enterButton />
            {state.persons && state.persons.length > 0 && (
                <List
                    loading={state.loading}
                    header={"人员列表"}
                    bordered
                    dataSource={state.persons}
                    renderItem={(item) => (
                        <List.Item
                            actions={[
                                <Popconfirm title="确定要移除当前人员吗?" placement="topRight" onConfirm={() => selectPerson(item)}>
                                    <a>设置为一级人员</a>
                                </Popconfirm>,
                            ]}
                        >
                            {/* {item.pmName} {persons.length > 1 && item.pmPhone && `(${item.pmPhone})`} */}
                            {item.omName}- {item.omPosi}
                        </List.Item>
                    )}
                />
            )}
        </Space>
    );
};

export default AddBoss;
